package Coursework;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ToDoListItem implements Serializable,Comparable<ToDoListItem>{
	private int id;
	private String content;
	private int priority;
	private Date dueDate;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public int getPriority() {
		return priority;
	}
	public void setPriority(int priority) {
		this.priority = priority;
	}
	public Date getDueDate() {
		return dueDate;
	}
	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}
	public ToDoListItem(String content, int priority, Date dueDate) {
		super();
		this.content = content;
		this.priority = priority;
		this.dueDate = dueDate;
	}
	public ToDoListItem() {
		super();
	}
	public String toString(){
		return "id : "+id+" ; content : "+content+" ; priority : "+priority+" ; due date : "+new SimpleDateFormat("yyyy-MM-dd").format(dueDate);
	}
	@Override
	public int compareTo(ToDoListItem o) {
		if(this.priority<o.priority){
			return -1;
		}else
		if(this.priority>o.priority){
			return 1;
		}else{
			if(this.dueDate.before(o.dueDate)){
				return -1;
			}else
			if(this.dueDate.after(o.dueDate)){
				return 1;
			}else{
				return 0;
			}
		}
		
	}
}
